| Total Complexity | 6 |
| Total Lines | 35 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | export type TensorInput = Array<TensorInput | bigint> |
||
| 13 | |||
| 14 | /** |
||
| 15 | * @class A tensor representing an immutable, multidimensional array of numbers with a defined shape and data type. |
||
| 16 | * @name Tensor |
||
| 17 | */ |
||
| 18 | export class Tensor { |
||
| 19 | values: BigInt[] = [] |
||
| 20 | shape: [number, number] |
||
| 21 | |||
| 22 | /** |
||
| 23 | * Initialize a tensor. |
||
| 24 | */ |
||
| 25 | constructor(values: TensorInput, shape?: [number, number]) { |
||
| 26 | this.shape = shape ?? [values.length, arrayDepth(values)] |
||
| 27 | for (let i = 0; i < this.shape[0]; i++) { |
||
| 28 | // const row = [] |
||
| 29 | // for (let j=0; j<this.shape[1]; j++) { |
||
| 30 | // // row.push(values[i][j]) |
||
| 31 | // } |
||
| 32 | this.values.push(0n) |
||
| 33 | } |
||
| 34 | } |
||
| 35 | |||
| 36 | /** |
||
| 37 | * The value. |
||
| 38 | */ |
||
| 39 | valueOf(): number { |
||
| 40 | return this.values.length |
||
| 41 | } |
||
| 42 | |||
| 43 | /** |
||
| 44 | * The text representation. |
||
| 45 | */ |
||
| 46 | toString(): string { |
||
| 47 | return this.values.toString() |
||
| 48 | } |
||
| 52 |